﻿using SqlSugar;
using Study.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace WpfApp4
{
    /// <summary>
    /// MyDataGrid2.xaml 的交互逻辑
    /// </summary>
    public partial class MyDataGrid2 : Window
    {
        public MyDataGrid2()
        {
            InitializeComponent();
        }

        private void BtnQuery_Click(object sender, RoutedEventArgs e)
        {
            ConnectionConfig connectionConfig = new ConnectionConfig()
            {
                ConnectionString = "Server = localhost; Database = wpf; Uid = root; Pwd = 123456; ",
                IsAutoCloseConnection = true,
                DbType = DbType.MySql
            };
            using (SqlSugarClient db = new SqlSugarClient(connectionConfig))
            {
                var list = db.Queryable<Course>().ToList();
                dataGrid.ItemsSource = list;
            }
        }
    }
}
